import matplotlib.pyplot as plt
import numpy as np
from scipy import signal

nmin = 0
nmax = 8
T = 0.01
n = np.arange(nmin, nmax + 1, 1)
nl = len(n)

def u(n):
   return np.where(n > 0, 1,0)


# 定义系统模型
num = np.array([1.0, -3.0, 3.0, -3.0])
den = np.array([1.0, 0.0, 0.0, 0.0])

t1, y1 = signal.dimpulse((num, den, 1), n=nl)  # 单位冲激响应
t2, y2 = signal.dstep((num, den, 1), n=nl)  # 单位阶跃响应

plt.rcParams['font.sans-serif'] = ['SimHei']  # 加上这一句就能在图表中显示中文
plt.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号

plt.subplot(211)
plt.stem(t1, np.squeeze(y1))

plt.subplot(212)
plt.stem(t2, np.squeeze(y2))

plt.show()
